﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Runtime.Remoting;
using System.Text;

namespace DMS.Business.Modules.Persister.Delegate {
    public class DelegateDbConnection : IDbConnection {


        private readonly IDbConnection _conn;

        public IDbConnection OriginalDbConnection {
            get { return _conn; }
        }

        public DelegateDbConnection(IDbConnection dbConnection) {
            this._conn = dbConnection;
        }

        public void Dispose() {
            _conn.Dispose();
        }

        public IDbTransaction BeginTransaction() {
            return new DelegateDbTransaction(_conn.BeginTransaction());
        }

        public IDbTransaction BeginTransaction(IsolationLevel il) {
            return new DelegateDbTransaction(_conn.BeginTransaction(il));
        }

        public void Close() {
            _conn.Close();
        }

        public void ChangeDatabase(string databaseName) {
            _conn.ChangeDatabase(databaseName);
        }

        public IDbCommand CreateCommand() {
            return _conn.CreateCommand();
        }

        public void Open() {
            _conn.Open();
        }

        public string ConnectionString {
            get { return _conn.ConnectionString; }
            set { _conn.ConnectionString = value; }
        }

        public int ConnectionTimeout {
            get { return _conn.ConnectionTimeout; }
        }

        public string Database {
            get { return _conn.Database; }
        }

        public ConnectionState State {
            get { return _conn.State; }
        }
    }
}
